import request from '@/utils/request';
import config from '@/env/config';
import { IWhitelist } from '@/types';

/**
 * 查询所有白名单
 * @returns string
 */
export function query(): Promise<IWhitelist[]> {
  return request({
    method: 'post',
    url: `${config.SERVICE_API}admin/whiteList/query`,
  });
}

/**
 * 启用禁用白名单
 * @returns string
 */
export function setStatus({ id, status }: { id: number; status: number }): Promise<void> {
  return request({
    method: 'post',
    data: {
      id,
      status,
    },
    url: `${config.SERVICE_API}admin/whiteList/setStatus`,
  });
}

/**
 * 删除白名单
 * @returns string
 */
export function del({ id }: { id: number }): Promise<void> {
  return request({
    method: 'post',
    data: { id },
    url: `${config.SERVICE_API}admin/whiteList/del`,
  });
}

/**
 * 新增白名单
 * @returns string
 */
export function add(data: IWhitelist): Promise<void> {
  return request({
    method: 'post',
    data,
    url: `${config.SERVICE_API}admin/whiteList/del`,
  });
}
